package org.xteam.sled.semantic;

public class Constraint {

	private Field field;
	private int low;
	private int high;

	public Constraint(Field field, int low, int high) {
		this.field = field;
		this.low = low;
		this.high = high;
	}
	
	public Field field() {
		return field;
	}
	
	public String toString() {
		return low + " <= " + field.name() + " < " + high;
	}

	public boolean isContradictory() {
		return low >= high;
	}

	public Constraint intersection(Constraint other) {
		return new Constraint(field, Math.max(low, other.low), Math.min(high, other.high));
	}

}
